package com.lakeworks.service.impl;

import com.lakeworks.common.core.domain.AjaxResult;
import com.lakeworks.common.domain.system.OprDefeimg;
import com.lakeworks.common.enums.FlagType;
import com.lakeworks.domain.vo.User;
import com.lakeworks.mapper.OprAttachmentMapper;
import com.lakeworks.mapper.OprDefeimgMapper;
import com.lakeworks.mapper.UserMapper;
import com.lakeworks.service.UserService;
import com.lakeworks.service.api.MerchantAsync;
import com.lakeworks.service.api.MerchantMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户 业务层处理
 *
 * @author lakeworks
 */
@Service
public class UserServiceImpl implements UserService {
    private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private OprDefeimgMapper oprDefeimgMapper;

    @Autowired
    private MerchantAsync merchantAsync;

    @Autowired
    private MerchantMap merchantMap;

    @Autowired
    private OprAttachmentMapper oprAttachmentMapper;

    @Autowired
    private ApplicationContext applicationContext;

    @Autowired
    private OprProductServiceImpl oprProductService;


    @Override
    public User getUserById(Long id) {
        return userMapper.selectUserById(id);
    }

    @Override
    public List<OprDefeimg> getList() {
        OprDefeimg build = OprDefeimg.builder().build();
        build.setId(61l);
        build.setFlag(FlagType.DELETE.value());
        oprDefeimgMapper.updateOprDefeimg(build);
        return null;
    }

    @Override
    public AjaxResult send() {
        //applicationContext.publishEvent(new DistributionEvent(this,"帅帅大sb"));
       /* HashSet<String> set = new HashSet<>();
        for (int i = 0; i < 500; i++){
            String washCode = oprProductService.getWashCode("13001");
            System.out.println("生成第"+i+"个水洗码::" + washCode);
            set.add(washCode);
        }*/
        //applicationContext.publishEvent(new NoConnectionEvent(this,1l));
        //merchantAsync.backPickState(PickUpStatus.builder().pickupNo("pickup_001").status("SIGNFOFF").build(), 1l);
        //merchantAsync.backProduct(ProductInfo.builder().pickupNo("112123").status("213123").build(),1l);
        return AjaxResult.success();
    }


    public AjaxResult size() {
        return AjaxResult.success();
    }
}
